home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 117 / PC Guia 117.iso / Software / Produtividade / Software3 / Product4 / Data1.cab / _183D711B970B4C7B995F7BF4C996DEC7 < prev    next >
Encoding:
Text File  |  2004-10-19  |  8.0 KB  |  254 lines

  1. /*******************************************************************/
  2. /*                                                                 */
  3. /*                      ADOBE CONFIDENTIAL                         */
  4. /*                   _ _ _ _ _ _ _ _ _ _ _ _ _                     */
  5. /*                                                                 */
  6. /* Copyright 2004 Adobe Systems Incorporated                       */
  7. /* All Rights Reserved.                                            */
  8. /*                                                                 */
  9. /* NOTICE:  All information contained herein is, and remains the   */
  10. /* property of Adobe Systems Incorporated and its suppliers, if    */
  11. /* any.  The intellectual and technical concepts contained         */
  12. /* herein are proprietary to Adobe Systems Incorporated and its    */
  13. /* suppliers and may be covered by U.S. and Foreign Patents,       */
  14. /* patents in process, and are protected by trade secret or        */
  15. /* copyright law.  Dissemination of this information or            */
  16. /* reproduction of this material is strictly forbidden unless      */
  17. /* prior written permission is obtained from Adobe Systems         */
  18. /* Incorporated.                                                   */
  19. /*                                                                 */
  20. /*******************************************************************/
  21.  
  22.  
  23. /*
  24. **-----------------------------------------------------------------------------
  25. ** Effect File Variables
  26. **-----------------------------------------------------------------------------
  27. */
  28.  
  29. uniform float4x4    gWorldViewProj : WorldViewProjection; // This matrix will be loaded by the application
  30. uniform float4x4    gWorldViewInverse;
  31. uniform float4x4    gWorldView;
  32. uniform float4        gLightPosition;
  33. uniform float4        gLightColor = float4(0.8,0.8,0.8,1.0);
  34. uniform float        gCurlAngle;
  35. uniform float        gAspectRatio;
  36. uniform float        gAnchorX;
  37. uniform float4        gEyePosition;
  38.  
  39. texture                gVideoTexture;
  40.  
  41.  
  42. /*
  43. **-----------------------------------------
  44. **        Sampler States
  45. **-----------------------------------------
  46. */
  47. //incoming video texture
  48. sampler Sampler = sampler_state
  49. {
  50.     Texture   = (gVideoTexture);
  51.     MipFilter = LINEAR;
  52.     MinFilter = LINEAR;
  53.     MagFilter = LINEAR;
  54. };
  55.  
  56. /*
  57. **-----------------------------------------------------------------------------
  58. ** Vertex Definitions
  59. **-----------------------------------------------------------------------------
  60. ** APP_OUTPUT is the structure in which we receive the vertices from the application
  61. */
  62. struct APP_OUTPUT
  63. {
  64.     float3 mPosition    : POSITION;
  65.     float3 mNormal        : NORMAL;
  66.     float2 mTexCoord    : TEXCOORD0;
  67.     
  68. };
  69.  
  70. /* 
  71. ** Pixel Shader structure declaration (For Foreground mesh)
  72. */
  73.  
  74. struct VS_OUTPUT 
  75. {
  76.   float4 mHPosition        : POSITION;        // coord position in window
  77.   float2 mTexcoord        : TEXCOORD0;    // wavy or fleck map texture coordinates
  78.   float3 mLightVec        : TEXCOORD1;        // position of light relative to point
  79.   float3 mHalfVec        : TEXCOORD2;        // Blinn halfangle
  80.   float3 mNormal        : TEXCOORD3;
  81. };
  82.  
  83. /* 
  84. ** Pixel Shader structure declaration (For Background Mesh)
  85. */
  86. struct PLAIN_VS_OUTPUT 
  87. {
  88.     float4 mHPosition        : POSITION;        // coord position in window
  89.     float2 mTexcoord        : TEXCOORD0;    // texture coordinates
  90. };
  91.  
  92.  
  93.  
  94. /*
  95. ** TEMP_OUT is a temporary structure for the ripple/Cyl Curl function
  96. */
  97. struct TEMP_OUT
  98. {
  99.     float4 mPosition    : POSITION;
  100.     float3 mNormal        : NORMAL0;
  101.     float3 mTangent;
  102.     float3 mBinormal;
  103. };
  104.  
  105. /*
  106. **------------------------------------------------
  107. **        Cylindrical Curl effect
  108. **------------------------------------------------
  109. */
  110. TEMP_OUT DoCylCurl(float3 position)
  111. {
  112.     TEMP_OUT returnVertex;
  113.     float sinVal, cosVal, curlRadius;
  114.     
  115.     float3x3 forwardMat, InvMat;
  116.     
  117.     sincos( gCurlAngle, sinVal, cosVal );
  118.     forwardMat = float3x3( float3(cosVal, sinVal, 0.0), float3(-sinVal, cosVal, 0.0), float3(0,0,1) );
  119.     sincos( -gCurlAngle, sinVal, cosVal );
  120.     InvMat = float3x3( float3(cosVal, sinVal, 0.0), float3(-sinVal, cosVal, 0.0), float3(0,0,1) );
  121.     
  122.     position = mul( forwardMat, position );
  123.     returnVertex.mPosition.xyz = position;
  124.     returnVertex.mPosition.w = 1.0f;
  125.     
  126.     returnVertex.mNormal = float3( 0.0f, 0.0f, 1.0f );
  127.     returnVertex.mBinormal = float3( 0, 1.0, 0 );    
  128.     
  129.     if ( position.x > gAnchorX )
  130.     {
  131.         //radius = 2/pi - factor*(distance to anchor)
  132.         curlRadius = 0.50 - 0.02*( position.x - gAnchorX );
  133.         float angle = ( position.x - gAnchorX )/curlRadius; // dist/Radius of curl
  134.         sincos( angle, sinVal, cosVal );
  135.         returnVertex.mPosition.x = gAnchorX + sinVal*curlRadius; // gAnchorX + R*SinVal
  136.         returnVertex.mNormal = float3( -sinVal, 0, abs(cosVal) );
  137.         returnVertex.mPosition.z = -0.50 + curlRadius*cosVal;
  138.     }
  139.     
  140.     returnVertex.mPosition.xyz = mul( InvMat, returnVertex.mPosition.xyz );
  141.     returnVertex.mBinormal = mul( InvMat, returnVertex.mBinormal );
  142.     returnVertex.mNormal = mul( InvMat, returnVertex.mNormal );
  143.     returnVertex.mTangent = cross( returnVertex.mBinormal, returnVertex.mNormal );
  144.     
  145.     return returnVertex;
  146. }
  147.  
  148.  
  149. /*
  150. **-------------------------------------------------------------------------
  151. ** PageCurl Transition effect - Vertex Shader (For ForeGround Mesh)
  152. **-------------------------------------------------------------------------
  153. */
  154. VS_OUTPUT pagecurl_transition_vs(APP_OUTPUT In)
  155. {
  156.     VS_OUTPUT Out;
  157.  
  158.     // copy texture coordinates
  159.     Out.mTexcoord.xy = In.mTexCoord.xy;
  160.     
  161.     TEMP_OUT tempVertex = DoCylCurl(float3(In.mPosition.x*gAspectRatio ,In.mPosition.yz));
  162.     
  163.     // transform vertex position into homogenous clip-space
  164.     Out.mHPosition = mul(gWorldViewProj, tempVertex.mPosition);
  165.     
  166.     // store light vector
  167.     Out.mLightVec = gLightPosition.xyz;
  168.        
  169.     //compute the half vector    
  170.     float4 eyePos = float4(0.0, 0.0, 1.5, 0.0);
  171.     Out.mHalfVec = normalize(Out.mLightVec + eyePos);
  172.     Out.mNormal = tempVertex.mNormal;
  173.     
  174.     Out.mHalfVec.z = dot( tempVertex.mNormal, Out.mHalfVec );
  175.  
  176.     
  177.     return Out;
  178. }
  179. /*
  180. **-------------------------------------------------------------------------
  181. ** PageCurl Transition effect - pixel Shader 1_3 (For ForeGround Mesh)
  182. **-------------------------------------------------------------------------
  183. */
  184.  
  185. float4 pagecurl_transition_ps_1_3(VS_OUTPUT In) : COLOR
  186. {   
  187.     float4 outColor, color1;
  188.     float diffuse, specular;
  189.     
  190.     color1 = tex2D( Sampler, In.mTexcoord );
  191.     
  192.     diffuse = dot ( In.mNormal, In.mLightVec );
  193.     specular = In.mHalfVec.z;
  194.     specular *= specular;
  195.     specular *= specular;
  196.     specular *= specular;
  197.     specular *= specular;
  198.     
  199.     outColor.xyz = color1*(diffuse) + (specular)*color1*float3(0.45,0.45,0.45);
  200.     outColor.a = color1.a;
  201.     
  202.     return outColor;
  203. }
  204.  
  205. /*
  206. **-------------------------------------------------------------------------
  207. ** Page Curl Transition effect - Plain Vertex Shader(For Background Mesh)
  208. **-------------------------------------------------------------------------
  209. */
  210. PLAIN_VS_OUTPUT pagecurl_transition_vs_plain(APP_OUTPUT In)
  211. {
  212.     PLAIN_VS_OUTPUT Out;
  213.  
  214.     // copy texture coordinates
  215.     Out.mTexcoord.xy = In.mTexCoord.xy;
  216.     
  217.     // transform vertex position into homogenous clip-space
  218.     Out.mHPosition = mul(gWorldViewProj,float4(In.mPosition.x*gAspectRatio,In.mPosition.y,In.mPosition.z,1.0f));
  219.     
  220.     return Out;
  221. }
  222.  
  223.  
  224. /*
  225. **-------------------------------------------------------------------------
  226. ** Page Curl Transition effect - plain pixel Shader 1_3(For Background Mesh)
  227. **-------------------------------------------------------------------------
  228. */
  229.  
  230. float4 pagecurl_transition_ps_1_3_plain(PLAIN_VS_OUTPUT In) : COLOR
  231. {   
  232.     float4 color1 = tex2D( Sampler, In.mTexcoord );
  233.     return color1;
  234. }
  235.  
  236. technique pagecurl_transition_1_3
  237. {
  238.     pass Pass0
  239.     {
  240.         //For Background Mesh (SourceB Video)
  241.         Sampler[0] = (Sampler); 
  242.         VertexShader = compile vs_1_1 pagecurl_transition_vs_plain();
  243.         PixelShader  = compile ps_1_3 pagecurl_transition_ps_1_3_plain();
  244.         
  245.     }
  246.     pass Pass1
  247.     {
  248.         //For Foreground Mesh (SourceA Video)
  249.         Sampler[0] = (Sampler); 
  250.         VertexShader = compile vs_1_1 pagecurl_transition_vs();
  251.         PixelShader  = compile ps_1_3 pagecurl_transition_ps_1_3();
  252.     }
  253. }
  254.